<template>
  <div class="login-page">
  <UserForm @onSubmit="onSubmit"/>
  </div>
</template>

<script>
import { loginAPI } from '@/api/user'
import UserForm from '@/components/UserForm.vue'
import { setToken } from '@/utils/storage'

export default {
  components: {
    UserForm
  },
  name: 'LoginPage',
  data () {
    return {}
  },
  methods: {
    async  onSubmit (values) {
      const res = await loginAPI(values)
      this.$toast('登录成功')
      setToken(res.data.token)
      this.$router.push('/')
    }
  }
}
</script>

<style lang="less" scoped>

</style>
